package com.hgk.wanwan.main.fragment.persentfragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.common.android.volley.VolleyError;
import com.hgk.common.common.ui.fragment.SimpleBaseFragment;
import com.hgk.wanwan.main.fragment.persentfragment.handeredit.AddImageActivity;
import com.hgk.wanwan.main.fragment.persentfragment.viewUI.Demo4Activity;
import com.hgk.wanwan.main.fragment.persentfragment.viewUI.GaistPlatActivity;
import com.hgk.wanwan.main.fragment.persentfragment.viewUI.GalleryActivity;
import com.hgk.wanwan.mvptest.View.WeatherActivity;

import java.util.Map;

import width.hgk.wanwan.R;


public class PercentFragment extends SimpleBaseFragment {

    private TextView mTvCollect,mTvHomePage,mTvFans,mTvFocus,mNotice;
    private TextView mTvDemoLogin;

    //title
    private LinearLayout mHeaderView;
    private TextView mTvTitle;
    private Button mBtnLeft,mBtnRight;

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView(view);
    }

    private void initView(View view) {
        mHeaderView = (LinearLayout) view.findViewById(R.id.header_persent_view);
        initHeaderView(mHeaderView);
        mTvCollect = (TextView) view.findViewById(R.id.tv_persent_collect_shoucang);
        mTvHomePage = (TextView) view.findViewById(R.id.tv_persent_zhuye);
        mNotice = (TextView) view.findViewById(R.id.tv_notice_percent);
        mTvFans = (TextView) view.findViewById(R.id.tv_fans);
        mTvDemoLogin = (TextView) view.findViewById(R.id.tv_persent_demo_login);
        mTvDemoLogin.setOnClickListener(this);
        mTvCollect.setOnClickListener(this);
        mTvHomePage.setOnClickListener(this);
        mNotice.setOnClickListener(this);
        mTvFans.setOnClickListener(this);
    }

    private void initHeaderView(LinearLayout v) {
        mTvTitle = (TextView) v.findViewById(R.id.tv_wherefrag_title);
        mBtnLeft = (Button) v.findViewById(R.id.btn_left_header);
        mBtnRight = (Button) v.findViewById(R.id.btn_right_header);
        mTvTitle.setVisibility(View.VISIBLE);
        mTvTitle.setText("我的");
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch(v.getId()){
            case R.id.tv_persent_collect_shoucang:
                GalleryActivity.launch(mContext);
                break;
            case R.id.tv_persent_zhuye:
                //实现EditText与TextView之间的直接转换
                Demo4Activity.launch(mContext);
                break;
            case R.id.tv_notice_percent:
                GaistPlatActivity.launch(mContext);
                break;
            case R.id.tv_fans:
                startActivity(new Intent(mContext, AddImageActivity.class));
                break;
            case R.id.tv_persent_demo_login://MVP的DEMOEshili
//                startActivity(new Intent(mContext, MainMvpActivity.class));
                startActivity(new Intent(mContext, WeatherActivity.class));
                break;
        }
    }

    @Override
    protected Map getApiParams() {
        return null;
    }

    @Override
    protected void success(String action, Object result) {

    }

    @Override
    protected void fail(String action, String errorStr) {

    }

    @Override
    protected void netfail(String action, VolleyError volleyError) {

    }

    @Override
    public void setLeftButton(RelativeLayout relativeLayout, Button button) {
        button.setVisibility(View.GONE);
    }

    @Override
    public void setRightButton(RelativeLayout relativeLayout, Button button) {

    }

    @Override
    public void setTitleView(LinearLayout linearlayout) {

    }

    @Override
    public Object getTitleString() {
        return "个人主页";
    }

    @Override
    public int getBodyView() {
        return R.layout.fragment_percent;
    }
}
